const Router=require("koa-router");
const db=require("../database");
const router=new Router();
router.get("/register",async function(ctx){

    let user=ctx.query;
    let result=db.registerUser(user);
    ctx.body=result;
   
});

router.get("/login",async function(ctx){

    let user=ctx.query;
    let result=db.findUser(user);
    if(result){
        ctx.body={
            flag:true,
            user:result
        }
    }else{
        ctx.body={
            flag:false,
            user:"该用户不存在"
        }
    }
   
});
router.get("/showUserList",async function(ctx){
    let result=db.findUserList();
    ctx.body=result;
});

module.exports.exerciseRouter=router;